<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
</head>
<style>
    .box {
        width: 80%;
        min-height: 320px;
        margin: 10px auto;
        border: 1px solid darkgoldenrod;
        border-radius: 10px;
    }
</style>

<body>
    <div id="app">
        <h1>{{title}}</h1>
    </div>
</body>

<script>
    // 定义路由组件
    const App = {
        template: "#main"
    }
    const Home = {
        template: "#home"
    }
    const List = {
        template: "#list"
    }
    const myFoot = {
        template: "#foot",
        data() {
            return {
                foots: [
                    { path: "home", name: "home", text: "Home" },
                    { path: "list", name: "list", text: "List" },
                    { path: "mine", name: "mine", text: "Mine" },
                ]
            }
        }
    }
    Vue.component("myFoot", myFoot)

    // 定义路由
    const routes = [
        {
            path: "/",
            name: "app",
            component: App,
            redirect: "/home",
            children: [
                { path: "home", name: "home", component: Home },
                { path: "list", name: "list", component: List },
            ]
        }
    ]

    const vm = new Vue({
        data: {
            title: "Vue Router 入门学习 - 路由守卫"
        },
    }).$mount("#app")
</script>

</html>